package resources;

import java.util.ArrayList;
import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.UriInfo;

import resources.teacher.TeachersRes;

import dao.Linker;
import dao.TeacherDAO;
import model.teacher.Department;

@Path("/teacher")
public class TeacherRes 
{
	@Context
	UriInfo uriInfo;
	
	@Context
	Request request;
	
	@GET
	@Produces(MediaType.TEXT_XML)
	public List<Department> getDataBrowser() 
	{
		Linker.sort();
		
		List<Department> departments = new ArrayList<Department>();
		departments.addAll(TeacherDAO.getDepartmentsCP().values() );
		return departments; 
	}
	
	@GET
	@Produces(MediaType.APPLICATION_JSON)
	public List<Department> getDataBrowserJSON() 
	{
		return getDataBrowser(); 
	}
	
	@GET
	@Produces(MediaType.APPLICATION_XHTML_XML)
	public List<Department> getDataBrowserXHTML() 
	{
		return getDataBrowser(); 
	}
	
	@GET
	@Produces(MediaType.APPLICATION_XML)
	public List<Department> getDataBrowserXML() 
	{
		return getDataBrowser(); 
	}

	@Path("{teachers}")
	public TeachersRes getSubData(@PathParam("teachers") String id) 
	{
		return new TeachersRes(uriInfo, request, id);
	}
}